﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using Happy.Web.Mvc;
using Happy.Cms.Controllers.Utils;
using Happy.Cms.Query.Articles;
using Tenoner.WebSite.Models;

namespace Tenoner.WebSite.Controllers
{
    public class PartialController : HappyController
    {
        //
        // GET: /Shared/

        public ActionResult Top()
        {
            return View();
        }

        public ActionResult Bottom()
        {
            return View();
        }

        public ActionResult TopServices()
        {
            return this.TopArticles("服务", "核心服务", "/Tenoner/Service/Index");
        }

        public ActionResult TopNews()
        {
            return this.TopArticles("动态", "最新动态", "/Tenoner/News/Index");
        }

        public ActionResult TopArticles()
        {
            return this.TopArticles("文章", "最新文章", "/Tenoner/Article/Index");
        }

        private ActionResult TopArticles(string category, string title, string moreHref)
        {
            var model = new TopArticleModel
            {
                Category = category,
                Title = title,
                MoreHref = moreHref,
                Articles = this.FindArticlesByCategoryName(category, 5)
            };

            return View("TopArticles", model);
        }
    }
}
